package com.woniu.new_orange.finance_model_guo.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.new_orange.entity.CompanyAccountFund;
import com.woniu.new_orange.entity.CompanyStream;
import com.woniu.new_orange.entity.PushLevel;
import com.woniu.new_orange.entity.Recommend;
import com.woniu.new_orange.finance_model_guo.Dto.CompanyStreamDto;
import com.woniu.new_orange.finance_model_guo.Vo.CompanyAccountVo;
import com.woniu.new_orange.finance_model_guo.Vo.CompanyStreamVo;
import com.woniu.new_orange.finance_model_guo.service.CompanyAccountFunds;
import com.woniu.new_orange.finance_model_guo.service.CompanyStreamService;
import com.woniu.new_orange.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Program: new_orange->CompanyStreamController
 * @Description: 公司流水
 * @Author: 谭少琛的爸爸
 * @Date: 2023-02-01 17:21
 * @Version： 1.0
 **/
@RestController
@RequestMapping("Comanys")
@Api(tags = "公司流水记录")
public class CompanyStreamController {
@Resource
    private CompanyStreamService companyStreamService;
@Resource
private CompanyAccountFunds companyAccountFunds;
@ApiOperation(value = "查全部",notes = "查全部加分页")
@PostMapping("queryAll")
public Result queryall(@RequestBody CompanyStreamDto companyStreamDto){
    PageHelper.startPage(companyStreamDto.getCurrentPage(),companyStreamDto.getPageSize(),true);
    List<CompanyStreamVo> companyStreams = companyStreamService.selectAll(companyStreamDto);
    PageInfo<CompanyStreamVo> pageInfo = new PageInfo<>(companyStreams);
    return Result.ok().data("CompanyStreamList",companyStreams).data("total",pageInfo.getTotal());
}
    @ApiOperation(value = "信息注入",notes = "字段注入")
    @GetMapping("{id}")
    public Result add(@PathVariable long id){
        CompanyAccountFund companyAccountFund = companyAccountFunds.selectByPrimaryKey(id);
        System.out.println(companyAccountFund);
        Integer companyAccountFundsId = companyAccountFund.getCompanyAccountFundsId();
        Date companyAccountFundsCreateTime = companyAccountFund.getCompanyAccountFundsCreateTime();
        BigDecimal companyAccountFundsActualAmount = companyAccountFund.getCompanyAccountFundsActualAmount();
        CompanyStream companyStream = new CompanyStream();
        companyStream.setCompanyStreamTime(companyAccountFundsCreateTime);
        companyStream.setCompanyStreamMoney(companyAccountFundsActualAmount);
        companyStream.setAccountFundsId(companyAccountFundsId);
        companyStreamService.insertSelective(companyStream);
        return  Result.ok();
    }
}
